package com.irdstudio.efp.report.service.impl;

import com.irdstudio.basic.framework.core.base.FrameworkService;


import com.irdstudio.efp.report.service.dao.RptHitCusInfoDao;
import com.irdstudio.efp.report.service.domain.RptHitCusInfo;
import com.irdstudio.efp.report.service.facade.RptHitCusInfoService;

import com.irdstudio.efp.report.service.vo.RptHitCusInfoVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 开发人员：【dengqiwen】<br/>
 * 功能描述：回溯命中客户信息明细报表（日报）<br/>
 */
@Service("rptHitCusInfoService")
public class RptHitCusInfoServiceImpl implements RptHitCusInfoService, FrameworkService {

	private static Logger logger = LoggerFactory.getLogger(RptHitCusInfoServiceImpl.class);

	@Autowired
	private RptHitCusInfoDao rptHitCusInfoDao;

	@Override
	public int insertOrUpdateBatch(List<RptHitCusInfoVO> list) throws Exception{
		logger.info("批量更新/插入回溯命中客户信息明细报表（日报）开始");
		int num = 0;
		try {
			num= this.rptHitCusInfoDao.insertOrUpdateBatch((List<RptHitCusInfo>)beansCopy(list, RptHitCusInfo.class));
		} catch (Exception e) {
			e.printStackTrace();
			String errorMsg="批量更新回溯命中客户信息明细报表（日报）异常："+e.getMessage();
			logger.error(errorMsg);
			num=-1;
			throw new Exception(errorMsg);
		}
		return num;
	}

	@SuppressWarnings("unchecked")
	public List<RptHitCusInfoVO> queryAll() throws Exception {
		logger.info("查询回溯命中客户信息明细报表（日报）:");
		List<RptHitCusInfoVO> list = null;
		try {
			List<RptHitCusInfo> infoList = rptHitCusInfoDao.queryAll();
			logger.info("当查询回溯命中客户信息明细报表（日报）结果集数量为:"+ infoList.size());
			list = (List<RptHitCusInfoVO>) beansCopy(infoList, RptHitCusInfoVO.class);
		} catch (Exception e) {
			e.printStackTrace();
			String errorMsg="查询回溯命中客户信息明细报表（日报）异常："+e.getMessage();
			logger.error(errorMsg);
			throw new Exception(errorMsg);
		}

		return list;

	}
}